package com.novax.ex.activity.provider.controller.inner;

import com.novax.ex.activity.open.api.inner.TaskEtRewardsApi;
import com.novax.ex.activity.open.model.query.TaskEtRewardsQuery;
import com.novax.ex.activity.open.model.response.task.TaskEtRewardsResponse;
import com.novax.ex.activity.provider.controller.BaseActivityController;
import com.novax.ex.activity.provider.service.TaskEtRewardsService;
import com.novax.ex.common.constant.InternationalCode;
import com.novax.ex.common.results.ReturnResult;
import com.novax.ex.common.util.PageUtil;
import org.springframework.web.bind.annotation.RestController;

import jakarta.annotation.Resource;
import java.math.BigDecimal;
import java.util.HashMap;
import java.util.Map;

/**
 * @Description 后台-奖励配置 controller
 * @Author ChenXi
 * @Date 2023/06/21/10:34
 */
@RestController
public class TaskEtRewardController extends BaseActivityController implements TaskEtRewardsApi {

    @Resource
    private TaskEtRewardsService taskEtRewardsService;

    @Override
    public ReturnResult<Map<String, BigDecimal>> findFrozen(Long userId) {
        Map<String, BigDecimal> map = taskEtRewardsService.findFrozen(userId);
        return ReturnResult.success(map);
    }

    @Override
    public ReturnResult<PageUtil<TaskEtRewardsResponse>> findPage(String language, TaskEtRewardsQuery query) {
        PageUtil<TaskEtRewardsResponse> page = new PageUtil<>(query);
        Map<String, Object> condition = new HashMap<>();
        condition.put("query", query);
        page.setCondition(condition);
        taskEtRewardsService.findPage(page, TaskEtRewardsResponse.class);
        return ReturnResult.success(getInternational(language, InternationalCode.QUERY_SUCCESS), page);
    }

    @Override
    public ReturnResult<TaskEtRewardsResponse> total(String language, TaskEtRewardsQuery query) {
        TaskEtRewardsResponse total = taskEtRewardsService.total(query);
        return ReturnResult.success(total);
    }
}
